Center in the frame. (#304482, Rob Staudinger, patch by Richard
authorMatthias Clasen <mclasen@redhat.com>
Tue, 2 Jan 2007 14:23:33 +0000 (14:23 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Tue, 2 Jan 2007 14:23:33 +0000 (14:23 +0000)
2007-01-02  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkentry.c (get_text_area_size): Center in the frame.
        (#304482, Rob Staudinger, patch by  Richard Stellingwerff)

svn path=/trunk/; revision=17015

ChangeLog
gtk/gtkentry.c

index da2ef38b87aca2beb747dacbea1fe67450bcea60..403fd8b593750d169a1a0df071092ffdf1e35163 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-01-02  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkentry.c (get_text_area_size): Center in the frame.  
+       (#304482, Rob Staudinger, patch by  Richard Stellingwerff)
+
 2007-01-02  Michael Emmel  <mike.emmel@gmail.com>
 
        * gdkwindow-directfb.c: fixed leak of dfb resource on destroy 
index 48758ddb2f3836f350ba2b85eb94cf92dc434a0e..a489064f65c7944abfd627e755b5fb3b08540eae 100644 (file)
@@ -1377,10 +1377,23 @@ get_text_area_size (GtkEntry *entry,
                     gint     *width,
                     gint     *height)
 {
+  gint frame_height;
   gint xborder, yborder;
   GtkRequisition requisition;
   GtkWidget *widget = GTK_WIDGET (entry);
+  gboolean interior_focus;
+  gint focus_width;
+
+  gtk_widget_style_get (widget,
+                        "interior-focus", &interior_focus,
+                        "focus-line-width", &focus_width,
+                        NULL);
+
+  gdk_drawable_get_size (widget->window, NULL, &frame_height);
 
+  if (GTK_WIDGET_HAS_FOCUS (widget) && !interior_focus)
+      height -= 2 * focus_width;
+  
   gtk_widget_get_child_requisition (widget, &requisition);
 
   _gtk_entry_get_borders (entry, &xborder, &yborder);
@@ -1389,8 +1402,8 @@ get_text_area_size (GtkEntry *entry,
     *x = xborder;
 
   if (y)
-    *y = yborder;
-  
+    *y = frame_height / 2 - (requisition.height - yborder * 2) / 2;
+
   if (width)
     *width = GTK_WIDGET (entry)->allocation.width - xborder * 2;